package Controller.Goods;


import Service.GoodsService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;

@WebServlet(name = "selectAllGoods", value = "/selectAllGoods")
public class SelectAllGoods extends HttpServlet {
    GoodsService goodsService = new GoodsService();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        String name = request.getParameter("name");
        String category = request.getParameter("goodscategory");
        String status = request.getParameter("status");
        try{
//            ProductCategoryDao dao = new ProductCategoryDao();
//            List<String> productList = dao.selectCategory();
            Map<String,Object> map = goodsService.selectAll(name,category,status);
//            request.setAttribute("productList",productList);
            request.setAttribute("map",map);
            System.out.println(map+"=");
            request.getRequestDispatcher("/ListGoods.jsp").forward(request,response);
        }catch (SQLException e){
            e.printStackTrace();
        }
    }
}